<?php
/**
 * @file test017.php
 * @package 
 * @subpackage 
 * @version $id: 0.1 UTF-8 2009-8-8 下午11:27:39 $
 * @author LD King (mifunny.info)
 * @copyright Copyright (c) 2007 - 2009 MiFunny China Inc. (http://mifunny.info)
 * 替换wp content 种的广告
 */

require_once 'config.inc.php';
try{ //数据库保持长连接
		$dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => true));
			$dbh->query('set names '.DB_CHARSET.';');
			$sql = "SELECT `ID` , `post_content` FROM `wp_posts` WHERE `ID` > 25000  LIMIT 0 , 5000 ";
			$res = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
			
			foreach($res as $re ){
			$ct = $re['post_content']; //echo $ct;
			$id = $re['ID'];
			$ct = str_replace ( "<script type=\"text/javascript\" src=\"http://www.7heart.com/v2/js/ads-single-middle.js\"></script>", "<!--adsense-->", $ct );
		//echo "\t\n\t\n".$ct;			
			$sql2 = "update `wp_posts` set `post_content`  = '{$ct}'  WHERE `ID` = '{$id}'";
				$reu = $dbh->query($sql2);
			echo "{$id}- <br />";
			}
		}catch(Exception $e){
   			die( "MySQL Conneting Failed: " . $e->getMessage() );
		}




?>